$(function () {
    getEnableManagerCount()
    getEnableNewsCount()
    getEnableContactCount()
    getEnableTeacherCount()
    getEnableProductCount()
    getCompany()
})

//获取可登录管理员数和所有管理员数
function getEnableManagerCount() {
    let res = request('http://localhost:8080/admin/manager/findAll', 'get', null)
    $('#allManager').html(res.count);
    let count = 0;
    res.data.forEach(function (e) {
        if (e.enable === 1)
            count += 1;
    })
    $('#enableManager').html(count);
}

//获取已公开新闻数
function getEnableNewsCount() {
    let res = request('http://localhost:8080/admin/news/findAll', 'get', null)
    $('#allNews').html(res.count);
    let count = 0;
    res.data.forEach(function (e) {
        if (e.enable === 1)
            count += 1;
    })
    $('#enableNews').html(count);
}

//获取需处理留言数
function getEnableContactCount() {
    let res = request('http://localhost:8080/admin/contact/findAll', 'get', null)
    $('#allContact').html(res.count);
    let count = 0;
    res.data.forEach(function (e) {
        if (e.enable === 1)
            count += 1;
    })
    $('#enableContact').html(count);
}

//获取私教数
function getEnableTeacherCount() {
    let res = request('http://localhost:8080/admin/teacher/findAll', 'get', null)
    let count = 0;
    res.data.forEach(function (e) {
        if (e.enable === 1)
            count += 1;
    })
    $('#enableTeacher').html(count);
}

//获取产品数
function getEnableProductCount() {
    let res = request('http://localhost:8080/admin/product/findAll', 'get', null)
    let count = 0;
    res.data.forEach(function (e) {
        if (e.enable === 1)
            count += 1;
    })
    $('#enableProduct').html(count);
}

//获取公司信息
function getCompany() {
    let res = request('http://localhost:8080/admin/company/find', 'get', null)
    $('#logo').attr('src', res.data.logoLocation)
    $('#chineseName').html(res.data.chineseName)
    $('#englishName').html(res.data.englishName)
    $('#introduction').html(res.data.introduction)
    $('#qq').html(res.data.qqId)
    $('#wb').html(res.data.wbId)
    $('#telephone').html(res.data.telephone)
    $('#email').html(res.data.email)
    $('#weChat').html(res.data.weChat)
    $('#address').html(res.data.address)
    $('#updateTime').html(res.data.updateTime)
    $('#remark').html(res.data.remark)
}

//修改公司信息
function companyEdit() {
    xadmin.open('公司信息修改', './companyEdit.html', 600, 400);
}